/*    */ package com.zimbra.cs.account.accesscontrol;
/*    */ 
/*    */ import com.zimbra.common.account.Key.DistributionListBy;
/*    */ import com.zimbra.common.localconfig.DebugConfig;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.cs.account.DistributionList;
/*    */ import com.zimbra.cs.account.Entry;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public abstract class CheckRight
/*    */ {
/*    */   protected Entry mTarget;
/*    */   protected Right mRightNeeded;
/*    */   protected boolean mCanDelegateNeeded;
/*    */   protected Provisioning mProv;
/*    */   protected TargetType mTargetType;
/*    */   
/*    */   protected CheckRight(Entry target, Right rightNeeded, boolean canDelegateNeeded)
/*    */     throws ServiceException
/*    */   {
/* 38 */     this.mProv = Provisioning.getInstance();
/*    */     
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/* 45 */     if (((target instanceof DistributionList)) && (!(target instanceof PseudoTarget.PseudoDistributionList))) {
/* 46 */       target = this.mProv.getDLBasic(Key.DistributionListBy.id, ((DistributionList)target).getId());
/*    */     }
/* 48 */     this.mTarget = target;
/*    */     
/* 50 */     this.mRightNeeded = rightNeeded;
/* 51 */     this.mCanDelegateNeeded = canDelegateNeeded;
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   public static boolean allowGroupTarget(Right rightNeeded)
/*    */     throws ServiceException
/*    */   {
/* 62 */     boolean allowed = !rightNeeded.isUserRight();
/*    */     
/* 64 */     if (rightNeeded.isUserRight())
/*    */     {
/*    */ 
/*    */ 
/*    */ 
/* 69 */       if (rightNeeded.getTargetType() == TargetType.account) {
/* 70 */         allowed = false;
/*    */       } else {
/* 72 */         allowed = true;
/*    */       }
/*    */       
/*    */     }
/*    */     else {
/* 77 */       allowed = !DebugConfig.disableGroupTargetForAdminRight;
/*    */     }
/* 79 */     return allowed;
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   static boolean rightApplicableOnTargetType(TargetType targetType, Right rightNeeded, boolean canDelegateNeeded)
/*    */   {
/* 88 */     if (canDelegateNeeded)
/*    */     {
/* 90 */       if (!rightNeeded.grantableOnTargetType(targetType)) {
/* 91 */         return false;
/*    */       }
/*    */       
/*    */     }
/* 95 */     else if (!rightNeeded.executableOnTargetType(targetType)) {
/* 96 */       return false;
/*    */     }
/*    */     
/* 99 */     return true;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/accesscontrol/CheckRight.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */